{**
 * Insurance company edit
 *
 * @package   OpenEMR
 * @link      http://www.open-emr.org
 * @author    Brady Miller <brady.g.miller@gmail.com>
 * @copyright Copyright (c) 2017 Brady Miller <brady.g.miller@gmail.com>
 * @license   https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
 *}
<form name="insurancecompany" method="post" action="{$FORM_ACTION}" class='form-horizontal' onsubmit="return top.restoreSession()">
    <!-- it is important that the hidden form_id field be listed first, when it is called it populates any old information attached with the id, this allows for partial edits
    if it were called last, the settings from the form would be overwritten with the old information-->
    <input type="hidden" name="form_id" value="{$insurancecompany->id|escape:'html'}">
    {if $insurancecompany->get_inactive() eq 1 }
    <div class="form-group">
        <label for="inactive" class="control-label col-sm-2">{xl t='Reactivate'|escape:'html'}</label>
        <div class="col-sm-8">
            <input type="checkbox" id="inactive" name="inactive" class="checkbox" value="0" />
        </div>
    </div>
    {/if}
    {if $insurancecompany->get_inactive() eq 0 }
    <div class="form-group">
        <label for="inactive" class="control-label col-sm-2">{xl t='Deactivate'|escape:'html'}</label>
        <div class="col-sm-8">
            <input type="checkbox" id="inactive" name="inactive" class="checkbox" value="1" />
        </div>
    </div>
    {/if}
    <div class="form-group">
        <label for="name" class="control-label col-sm-2">{xl t='Name'|escape:'html'}</label>
        <div class="col-sm-8">
            <input type="text" id="name" name="name" class="form-control" aria-describedby="nameHelpBox" value="{$insurancecompany->get_name()|escape:'html'}" onKeyDown="PreventIt(event)">
            <span id="nameHelpBox" class="help-block">({xl t='Required'|escape:'html'})</span>
        </div>
    </div>
    <div class="form-group">
        <label for="attn" class="control-label col-sm-2">{xl t='Attn'|escape:'html'}</label>
        <div class="col-sm-8">
            <input type="text" id="attn" name="attn" class="form-control" value="{$insurancecompany->get_attn()|escape:'html'}" onKeyDown="PreventIt(event)">
        </div>
    </div>
    <div class="form-group">
        <label for="address_line1" class="control-label col-sm-2">{xl t='Address'|escape:'html'}</label>
        <div class="col-sm-8">
            <input type="text" id="address_line1" name="address_line1" class="form-control" value="{$insurancecompany->address->line1|escape:'html'}" onKeyDown="PreventIt(event)">
        </div>
    </div>
    <div class="form-group">
        <label for="address_line2" class="control-label col-sm-2">{xl t='Address'|escape:'html'}</label>
        <div class="col-sm-8">
            <input type="text" id="address_line2" name="address_line2" class="form-control" value="{$insurancecompany->address->line2|escape:'html'}" onKeyDown="PreventIt(event)">
        </div>
    </div>
    <div class="form-group">
        <label for="city" class="control-label col-sm-2">{xl t='City'|escape:'html'}</label>
        <div class="col-sm-8">
            <input type="text" id="city" name="city" class="form-control" value="{$insurancecompany->address->city|escape:'html'}" onKeyDown="PreventIt(event)">
        </div>
    </div>
    <div class="form-group">
        <label for="state" class="control-label col-sm-2">{xl t='State'|escape:'html'}</label>
        <div class="col-sm-8">
            <input type="text" maxlength="2" id="state" name="state" class="form-control" value="{$insurancecompany->address->state|escape:'html'}" onKeyDown="PreventIt(event)">
        </div>
    </div>
    <div class="form-group">
        <label for="zip" class="control-label col-sm-2">{xl t='Zip Code'|escape:'html'}</label>
        <div class="col-sm-8">
            <input type="text" id="zip" name="zip" class="form-control" value="{$insurancecompany->address->zip|escape:'html'}" onKeyDown="PreventIt(event)">
        </div>
    </div>
    <div class="form-group">
        <label for="phone" class="control-label col-sm-2">{xl t='Phone'|escape:'html'}</label>
        <div class="col-sm-8">
            <input type="text" id="phone" name="phone" class="form-control" value="{$insurancecompany->get_phone()|escape:'html'}" onKeyDown="PreventIt(event)">
        </div>
    </div>
    <div class="form-group">
        <label for="cms_id" class="control-label col-sm-2">{xl t='CMS ID'|escape:'html'}</label>
        <div class="col-sm-8">
            <input type="text" id="cms_id" name="cms_id" class="form-control" value="{$insurancecompany->get_cms_id()|escape:'html'}" onKeyDown="PreventIt(event)">
        </div>
    </div>
    {if $SUPPORT_ENCOUNTER_CLAIMS}
        <div class="form-group">
            <label for="alt_cms_id" class="control-label col-sm-2">{xl t='CMS ID For Encounter Claims'}</label>
            <div class="col-sm-8">
                <input type="text" id="alt_cms_id" name="alt_cms_id" class="form-control" value="{$insurancecompany->get_alt_cms_id()|escape:'html'}" onKeyDown="PreventIt(event)">
            </div>
        </div>
    {/if}
    <div class="form-group">
        <label for="ins_type_code" class="control-label col-sm-2">{xl t='Payer Type'|escape:'html'}</label>
        <div class="col-sm-8">
            <select id="ins_type_code" name="ins_type_code" class="form-control">
                {html_options options=$insurancecompany->ins_type_code_array selected=$insurancecompany->get_ins_type_code()}
            </select>
        </div>
    </div>
    <div class="form-group">
        <label for="x12_default_partner_id" class="control-label col-sm-2">{xl t='Default X12 Partner'|escape:'html'}</label>
        <div class="col-sm-8">
            <select id="x12_default_partner_id" name="x12_default_partner_id" class="form-control">
                {html_options options=$x12_partners selected=$insurancecompany->get_x12_default_partner_id()}
            </select>
        </div>
    </div>
    <div class="btn-group col-sm-offset-2">
        <a href="javascript:submit_insurancecompany();" class="btn btn-default btn-save" onclick="top.restoreSession()">
            {xl t='Save'|escape:'html'}
        </a>
        <a href="controller.php?practice_settings&insurance_company&action=list" class="btn btn-link btn-cancel" onclick="top.restoreSession()">
            {xl t='Cancel'|escape:'html'}
        </a>
    </div>
    <input type="hidden" name="id" value="{$insurancecompany->id|escape:'html'}" />
    <input type="hidden" name="process" value="{$PROCESS|escape:'html'}" />
</form>

{literal}
<script language="javascript">
    function submit_insurancecompany() {
        if(document.insurancecompany.name.value.length>0) {
            top.restoreSession();
            document.insurancecompany.submit();
            //Z&H Removed redirection
        } else{
            document.insurancecompany.name.style.backgroundColor="red";
            document.insurancecompany.name.focus();
        }
    }

    function jsWaitForDelay(delay) {
        var startTime = new Date();
        var endTime = null;
        do {
            endTime = new Date();
        } while ((endTime - startTime) < delay);
    }
</script>
{/literal}